import { service } from '@/utils/request'

export function getAllCourse() {
    return service({
      url: `/api//course/get`,
      method: 'get'
    })
}

export function getCourse(pageNum, pageSize) {
  return service({
    url: `/api//course/get/${pageNum}/${pageSize}`,
    method: 'get'
  })
}

export function getCourseById(id) {
  return service({
    url: `/api//course/authSearch/${id}`,
    method: 'get'
  })
}

export function addCourse(params) {
  return service({
    url: `/api//course/add`,
    method: 'post',
    params
  })
}

export function editCourse(id, params) {
  return service({
    url: `/api//course/update/${id}`,
    method: 'put',
    params
  })
}

export function deleteCourse(id) {
  return service({
    url: `/api//course/delete/${id}`,
    method: 'delete',
  })
}

export function searchCourse(queryInfo) {
  return service({
    url: `/api//course/search/{name}/${queryInfo.pageNum}/${queryInfo.pageSize}?name=${queryInfo.query}`,
    method: 'get',
  })
}

//视频相关
export function addVideo(params) {
  return service({
    url: `/api//course_video/add`,
    method: 'post',
    data: params
  })
}

export function getVideo(id) {
  return service({
    url: `/api/course_video/get/${id}`,
    method: 'get'
  })
}

export function editVideo(id, params) {
  return service({
    url: `/api/course_video/update/${id}`,
    method: 'put',
    data: params
  })
}

export function deleteVideo(id) {
  return service({
    url: `/course_video/delete/${id}`,
    method: 'delete'
  })
}

// 通过id获取高校
export function getUnivById(id) {
  return service({
    url: `/orgs/univ/${id}`,
    method: 'get'
  })
}

export function getUnivByName(schoolname) {
  return service({
    url: `/orgs/univ/searchUnivByUnivNameNoPage?schoolname=${schoolname}`,
    method: 'get'
  })
}

// 获取所有高校
export function getUniv() {
  return service({
    url: `/orgs/univ/1/10`,
    method: 'get'
  })
}

// 获取课程排名
export function getCourseRange() {
  return service({
    url: `/course/sortByScore/1/10`,
    method: 'get'
  })
}